#include <stdlib.h> 
#include <sys/ioctl.h> 
#include <unistd.h> 
#include <sys/types.h> 
#include <sys/stat.h> 
#include <fcntl.h> 
#include <sys/mman.h>
 
#define DEVICE_GPIODRV "/dev/fl2440_pwm" 
int main() {
int fd;
int cmd;
char *data;

if((fd=open(DEVICE_GPIODRV,O_RDWR | O_NONBLOCK))<0)//打开驱动   
{
	printf("open device: %s\n",DEVICE_GPIODRV);
	perror("can not open device");     
	exit(1);
}

while(1)
{
	cmd = 0;
	if(cmd != 0)
	{
		printf("输入频率(0停止):\n");
		scanf("%d",&cmd);
	}
	//usleep(50000);

	if(cmd > 0){
		ioctl(fd,cmd); 
	}
	else{
		ioctl(fd,0);
	}
}

close(fd);
return 0; 
}

